package com.aspose.cells;

import java.util.HashMap;
import java.util.Iterator;

class zaiv {
   private Workbook a = null;
   private HashMap b = new HashMap();
   private static final com.aspose.cells.b.c.a.za c = new com.aspose.cells.b.c.a.za(new String[]{"contentTypeSchema", "FormTemplates", "properties", "documentManagement"});

   zaiv(Workbook var1) {
      this.a = var1;
   }

   void a(zvh var1) throws Exception {
      String var2 = "MsoDataStore";
      if (var1 != null && var1.a().b(var2)) {
         zane var3 = (zane)var1.a().d(var2);

         znf var6;
         for(Iterator var4 = var3.f().iterator(); var4.hasNext(); this.a.m().a(var6)) {
            zane var5 = (zane)var4.next();
            var6 = new znf();
            com.aspose.cells.b.a.d.zh var7 = (com.aspose.cells.b.a.d.zh)var5.d("item");
            if (var7 != null) {
               var6.a = var7.o();
            }

            var7 = (com.aspose.cells.b.a.d.zh)var5.d("Properties");
            if (var7 != null) {
               var6.b = var7.o();
            }
         }

         var1.a().g(var2);
      }

   }

   void a() throws Exception {
      zng var1 = this.a.g;
      if (var1 != null && var1.getCount() != 0) {
         zcfw var2 = null;
         zcfw var3 = null;
         boolean[] var4 = new boolean[var1.getCount()];

         int var5;
         for(var5 = var1.getCount() - 1; var5 >= 0; --var5) {
            zcfw var6 = new zcfw(new com.aspose.cells.b.a.d.zh(var1.a(var5).a()));
            var6.b(true);
            this.c(var6);
            switch(c.a(var6.p())) {
            case 0:
               var2 = var6;
            case 1:
               break;
            case 2:
               var3 = var6;
               break;
            default:
               continue;
            }

            var4[var5] = true;
         }

         if (var2 != null) {
            for(var5 = var1.getCount() - 1; var5 >= 0; --var5) {
               if (var4[var5]) {
                  var1.removeAt(var5);
               }
            }

            this.a(var2);
            if (var3 == null) {
               this.a(this.a.getCustomDocumentProperties());
            } else {
               this.b(var3);
            }
         }

         if (var1.getCount() == 0) {
            this.a.g = null;
         }

      }
   }

   void a(zcfw var1) throws Exception {
      zaiu var2 = new zaiu(this.a.f);
      var2.a(var1);
   }

   private void a(CustomDocumentPropertyCollection var1) {
      Iterator var2 = this.a.f.iterator();

      while(var2.hasNext()) {
         ContentTypeProperty var3 = (ContentTypeProperty)var2.next();
         DocumentProperty var4 = var1.get(var3.getName());
         if (var4 != null) {
            var3.setValue(com.aspose.cells.b.a.zr.a(var4));
            var1.remove(var4.getName());
         }
      }

   }

   void b(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(zass.a(var1)) {
            switch(c.a(var1.p())) {
            case 3:
               this.a(var1, this.a.f);
            }
         }

      }
   }

   void a(zcfw var1, ContentTypePropertyCollection var2) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(zass.a(var1)) {
            ContentTypeProperty var3 = var2.get(var1.p());
            var3.c = var1.a("xmlns");
            this.b.put(var3.c, var3);
            var2.b = var3.c;
            var3.setName(var1.p());
            if (!var1.n()) {
               var3.setValue(var1.b());
            } else {
               var1.a();
            }
         }

      }
   }

   private boolean c(zcfw var1) throws Exception {
      var1.j();
      return true;
   }
}
